package com.changlu._01单例设计模式;

/**
 * @ClassName HolderSingle
 * @Author ChangLu
 * @Date 2022/2/16 18:21
 * @Description 静态内部类获取单例（懒加载）
 */
public class HolderSingle {

    private HolderSingle(){
    }

    private static class SingleHolder{
        private static HolderSingle instance = new HolderSingle();

        //当调用静态方法时，该静态类才会进行static变量初始化操作
        public static HolderSingle getInstance(){
            return instance;
        }
    }

    //测试
    public static void main(String[] args) {
        System.out.println(HolderSingle.SingleHolder.getInstance());
    }

}